public class MyQueue<T> {
    private Object[] arr;
    private int front, rear, size, capacity;
    public MyQueue(int cap) {
        arr = new Object[cap];
        front = 0; rear = 0; size = 0; capacity = cap;
    }
    public void enqueue(T item) {
        if (size < capacity) {
            arr[rear] = item;
            rear = (rear + 1) % capacity;
            size++;
        }
    }
    public T dequeue() {
        if (size == 0) return null;
        T item = (T)arr[front];
        front = (front + 1) % capacity;
        size--;
        return item;
    }
    public boolean isEmpty() { return size == 0; }
}